<?php 
class ImportExcel extends Module{
	function ImportExcel($row){		
		
		if(User::have_permit(array(ADMIN_ITEM)))
		{
			Module::Module($row);	
			
			$cmd=Url::get('cmd');
			
			switch ($cmd){
				case 'download':
					$file_src = DATA_PATH."AzNet.xls";
							
					if(file_exists(ROOT_PATH.$file_src))
					{
						$ext = AZLib::getExtension($file_src);
						
						if($ext && strlen($ext) <= 5)
						{
							$ext_app = substr($ext,1);
								
							header("Content-type: application/$ext_app");
							header("Content-Disposition: attachment; filename=".date("Y.m.d-H\hi",TIME_NOW)."_ANS_Products$ext");
							
							readfile(ROOT_PATH.$file_src);
							exit;
						}
					}
					
					header("HTTP/1.0 404 Not Found");
					echo "<h1>404 - Not Found!<br />Return to <a href='".WEB_ROOT."'>".WEB_NAME."</a></h1>";
					exit;
					break;
				default:
					require_once 'forms/ImportExcel.php';
					$this->add_form(new ImportExcelForm());
				break;
			}
		}
		else{
			Url::access_denied();	
		}
	}
}
?>